﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace NczControlLibrary.Controls {
    [TemplatePart(Name = "_Border", Type = typeof(Border))]
    public class Gborder : Control {
        public Gborder() {
            DefaultStyleKey = typeof(Gborder);
            this.Loaded += Gborder_Loaded;
        }
        Border border;
        public static explicit operator Border(Gborder b) {
            return b.border;
        }
        public override void OnApplyTemplate() {
            this.border = this.GetTemplateChild("_Border") as Border;
            base.OnApplyTemplate();
        }

        void Gborder_Loaded(object sender, RoutedEventArgs e) {
            GraphCommand.Execute(this.border);
        }
        #region dependency properties
        public static readonly DependencyProperty GraphCommandProperty = DependencyProperty.Register("GraphCommand", typeof(ICommand), typeof(Gborder), new PropertyMetadata(default(ICommand), (o, k) => {
        }));
        public ICommand GraphCommand { get { return (ICommand)this.GetValue(GraphCommandProperty); } set { this.SetValue(GraphCommandProperty, value); } }
        public static readonly DependencyProperty ChildProperty = DependencyProperty.Register("Child", typeof(object), typeof(Gborder), new PropertyMetadata(default(object), (o, k) => {
        }));
        public object Child { get { return (object)this.GetValue(ChildProperty); } set { this.SetValue(ChildProperty, value); } }
        public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(double), typeof(Gborder), new PropertyMetadata(default(double), (o, k) => {
        }));
        public double CornerRadius { get { return (double)this.GetValue(CornerRadiusProperty); } set { this.SetValue(CornerRadiusProperty, value); } }
        #endregion
    }
}
